<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>

</head>
<body class="gray-bg">

	<!--隐藏域-->
	<input type="hidden" value="${busiId}" id="busiId" name="busiId" />
	<!--隐藏域-->

	<div class="container creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷后业务>客户申请退押金</span>
		</div>
		<div class="ibox-content ibox-con">
			<div class="buttonfixed">
				<button type="button" class="btn dpbtn_blue btnaplly"
					onclick="save();">保存提交</button>
			</div>
			<%@include file="/jsp/common_yw_with_loan_include.jsp"%>
			
			<div class="business-manwife">额外信息</div>
			<div class="business-padding">
				<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
					<tr>
						<td align="right"><label class="control-label np">车辆类型：</label></td>
						<td><input class="form-control" readonly="readonly" value="${ywBusinessCar.carType}"/></td>
						<td align="right"><label class="control-label np">贷款类型：</label></td>
						<td><input class="form-control" readonly="readonly" value="${ywBusinessLoan.loanType}"/></td>	
					</tr>
					<tr>
						<td align="right"><label class="control-label np">当前连续逾期次数：</label></td>
						<td><input class="form-control" readonly="readonly" value="${dhOverdueList.overdueCountContinuous}"/></td>
						<td align="right"><label class="control-label np">累计逾期次数：</label></td>
						<td><input class="form-control" readonly="readonly" value="${dhOverdueList.overdueCountTotal}"/></td>	
					</tr>
					<tr>
						<td align="right"><label class="control-label np">已代偿金额：</label></td>
						<td><input class="form-control" readonly="readonly" value="${dhInsteadPayment.balance}"/></td>
						<td align="right">&nbsp;</td>
						<td align="right">&nbsp;</td>
					</tr>
				</table>
			</table>
			<br/>
			<div class="business-manwife">退款信息</div>
			<div class="business-padding">
				<table cellpadding="0" cellspacing="0" border="0" class="table-list">
					<tr>
						<td>签约贷款额</td>
						<td id="sign_loan_amount" name="sign_loan_amount">&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td>还款情况</td>
						<td id="yq_count" name="yq_count">&nbsp;</td>
						<td id="jq_count" name="jq_count">&nbsp;</td>
						<td>当前逾期<span id="amount_remainder" name="amount_remainder"></span>元
						</td>
					</tr>
					<tr>
						<td>征信押金</td>
						<td id="credit_real" name="credit_real">&nbsp;</td>
						<td>续保押金</td>
						<td id="deposit_insure_real" name="deposit_insure_real">&nbsp;</td>
					</tr>
					<tr>
						<td>履约押金</td>
						<td id="deposit_performing_real" name="deposit_performing_real">&nbsp;</td>
						<td>抵押押金</td>
						<td id="deposit_real" name="deposit_real">&nbsp;</td>
					</tr>
				</table>
				<form class="form-horizontal m-t" id="commentForm">
					<div class="business-padding">
						<table cellpadding="0" cellspacing="0" border="0"
							class="buyinfor-table">
							<tr>
								<td align="right"><label class="control-label np">退款项目：</label>
								</td>
								<td><input id="typeRefund" name="typeRefund" minlength="1"
									maxlength="20" type="text" class="form-control" required=""
									aria-required="true" placeholder="退款项目(必填)"></td>
								<td align="right"><label class="control-label np">退款银行：</label>
								</td>
								<td><input id="bank" name="bank" minlength="1"
									maxlength="20" type="text" class="form-control" required=""
									aria-required="true" placeholder="退款银行(必填)"></td>
							</tr>

							<tr>
								<td align="right"><label class="control-label np">退款单位：</label>
								</td>
								<td><input id="departmentRefund" name="departmentRefund"
									minlength="1" maxlength="20" type="text" class="form-control"
									required="" aria-required="true" placeholder="退款单位(必填)">
								</td>
								<td align="right"><label class="control-label np">银行账号：</label>
								</td>
								<td><input id="cardnoRefund" name="cardnoRefund"
									minlength="1" maxlength="20" type="text" class="form-control"
									required="" aria-required="true" placeholder="银行账号(必填)">
								</td>
							</tr>

							<tr>
								<td align="right"><label class="control-label np">申请金额：</label>
								</td>
								<td><input id="amountApply" name="amountApply"
									minlength="1" maxlength="20" type="text" class="form-control"
									required="" aria-required="true" placeholder="申请金额(必填)">
								</td>
								<td align="right"><label class="control-label np">实际金额：</label>
								</td>
								<td><input id="amountRefund" name="amountRefund"
									minlength="1" maxlength="20" type="text" class="form-control"
									required="" aria-required="true" placeholder="实际金额(必填)">
								</td>
							</tr>

							<tr>
								<td align="right"><label class="control-label np">退款方式：</label>
								</td>
								<td><select class="select-control" required="required" id="typeRemit"
									name="typeRemit"></select></td>

							</tr>
							<tr>
								<td align="right" valign="top"><label
									class="control-label np">备注：</label></td>
								<td colspan="3"><textarea id="remarks" name="remarks"
										class="form-control" aria-required="true"></textarea></td>
							</tr>
							
							<input type="hidden" value="${busiId}" id="ywid" name="ywid" />
						</table>
					</div>
				</form>
			</div>
			<div class="business-manwife">退款附件</div>
			<div class="business-padding">
				<div class="zx-addimg">
					<ul id="TUI_KUAN_FU_JIAN">
						<li>
							<img filelabel="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN1 }"
							src="${basePath}/img/shangchuanzhaopian.png" width="110px" height="110px" class="zx-imgPre ${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN1 }">
							<span filelabelDelSpan="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN1 }" class="hidden bt-cancle glyphicon glyphicon-trash" onclick="deleleFileRecord(this,'${attachmentLabelNameValues.TUI_KUAN_FU_JIAN_FUJIAN1 }',false);"></span>
							<div class="img-layer">
								<div></div>
								<span filelabelLabelSpan="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN1 }">${attachmentLabelNameValues.TUI_KUAN_FU_JIAN_FUJIAN1 }</span>
							</div>
							<div filelabelDiv="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN1 }" class="hidden button-des">
								<a type="button" class="abuttonStylele"  filelabelADown="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN1 }" download="shangchuanzhaopian.png" href="${basePath}/img/shangchuanzhaopian.png" >下载</a>
								<a type="button" class="abuttonStyleri" onclick="showImg(this);">详情</a>
							</div>
							<a href="javascript:void(0);" class="file">
								<input type="file"  accept="image/gif,image/jpeg,image/bmp,image/png,image/jpg"  onchange="uploadFile(this,'${modeIDTypeNames.TUIKUAN}','TUI_KUAN_FU_JIAN',false, false,null,null,'${uuid}');"/>
							</a>
						</li>
						
						<li>
							<img filelabel="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN2 }"
							src="${basePath}/img/shangchuanzhaopian.png" width="110px" height="110px" class="zx-imgPre ${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN2 }">
							<span filelabelDelSpan="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN2 }" class="hidden bt-cancle glyphicon glyphicon-trash" onclick="deleleFileRecord(this,'${attachmentLabelNameValues.TUI_KUAN_FU_JIAN_FUJIAN2 }',false);"></span>
							<div class="img-layer">
								<div></div>
								<span filelabelLabelSpan="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN2 }">${attachmentLabelNameValues.TUI_KUAN_FU_JIAN_FUJIAN2 }</span>
							</div>
							<div filelabelDiv="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN2 }" class="hidden button-des">
								<a type="button" class="abuttonStylele"  filelabelADown="${attachmentLabelNames.TUI_KUAN_FU_JIAN_FUJIAN2 }" download="shangchuanzhaopian.png" href="${basePath}/img/shangchuanzhaopian.png" >下载</a>
								<a type="button" class="abuttonStyleri" onclick="showImg(this);">详情</a>
							</div>
							<a href="javascript:void(0);" class="file">
								<input type="file" accept="image/gif,image/jpeg,image/bmp,image/png,image/jpg"   onchange="uploadFile(this,'${modeIDTypeNames.TUIKUAN}','TUI_KUAN_FU_JIAN',false, false,null,null,'${uuid}');" />
							</a>
						</li>
						
					</ul>
				</div>
			</div>
			<div class="business-manwife">经办信息</div>
			<div class="padding-nono">
				<table cellpadding="0" cellspacing="0" border="0"
					class="buyinfor-table">
					<tr>
						<td align="right"><label class="control-label np">经办人：</label>
						</td>
						<td><input class="form-control" type="text" id="" name=""
							readonly="readonly" value="${current_user_key.uname}" /></td>
						<td align="right"><label class="control-label np">经办时间：</label>
						</td>
						<td><input id="jb_time" name="jb_time" placeholder="经办时间"
							class="laydate-icon form-control" readonly="readonly" /></td>
					</tr>
				</table>
			</div>
			</form>
		</div>
	</div>
	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- 文件上传 -->
	<%@include file="/jsp/common_fileupload_include.jsp"%>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript"></script>
	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    jQuery(function($) {  
	    	initData();
	    	var date = new Date();
	    	document.getElementById("jb_time").value = date.format("yyyy-MM-dd h:m:s");
	    });
	    
	    var initData = function()
	    {
	    	var busiId = $('#busiId').val();
	    	$.dpAjax({
		   		url:'${basePath}/DaiHouYwController/getKeHuTuiYaJinList',
		   		data:{"busiId":busiId},
				success: function(datas)
				{
			 	  if(datas.flag == "100100")
			 	  {
			 		  layer.msg(datas.message, {icon: 1});  
			 		  var ywBusiness = datas.ywBusiness;
			 		  if(ywBusiness)
			 		  {
			 			  $('#sign_loan_amount').html(ywBusiness.signLoanAmount);
			 		  }
			 		
			 		  var cwIncomeExpensesItem = datas.cwIncomeExpensesItem;
			 		
			 		  if(cwIncomeExpensesItem)
			 		  {
			 			  for(var i=0;i<cwIncomeExpensesItem.length;i++)
			 			  {
			 				  var pp = cwIncomeExpensesItem[i];
			 				  
			 				  var item_code = pp['item_code'];
			 				  var amount_item = pp['amount_item'];
			 				  
			 				  if(item_code == "25")
			 				  {
			 					   //续保押金  25
			 					   $('#deposit_insure_real').html(amount_item);
			 				  }
			 				  else if(item_code == "03")
			 				  {
			 					  //履约押金  03
			 					  $('#deposit_performing_real').html(amount_item);
			 				  }
			 				  else if(item_code == "29")
			 				  {
			 					  //抵押押金  29
			 					  $('#deposit_real').html(amount_item);
			 				  }
			 				  else if(item_code == "34")
			 				  {
			 					  //征信押金  34
			 					  $('#credit_real').html(amount_item);
			 				  }
			 			  }
			 		  }
			 		  
			 		  var amount_remainder = 0;
			 		  var dhoverdueList = datas.dhoverdueList;
			 		  if(dhoverdueList)
			 		  {
			 			 for(var key in dhoverdueList)
			 			 {
			 				var objs = dhoverdueList[key];
			 				var item = objs['amount_remainder'];
			 				amount_remainder = item;
			 			 }
			 		  }
			 		  
			 		  $('#amount_remainder').html(amount_remainder);
			 		  
			 		  var objs = '';
			 		  var settlement_type = datas.settlement_type;
			 		  for(var key in settlement_type)
			 		  {
			 			  objs += '<option value="'+key+'">'+settlement_type[key]+'</option>';
			 		  }
			 		  $('#typeRemit').html(objs);
					  return;
				  }
				  if(datas.flag == "100200"){
					  alert(JSON.stringify(datas));
		              return;
		          }
				  layer.msg(datas.message, {icon: 2});
				}
		   });
	    }
	    
	    //保存提交
	    var save = function()
	    {
	    	//询问框
	    	layer.confirm('确认是否执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
	    	  btn: ['确定','取消'] //按钮
	    	}, function(){
	    		layer.closeAll();
	    		var validstatus = $("#commentForm").valid();
		    	if(validstatus)
		    	{
		    		var data = $('#commentForm').serialize();
		    		$.dpAjax({
		 	    		url:'${basePath}/DaiHouYwController/daiHouYwKeHuTuiKuan',
		     			data:data,
		     			success: function(datas){
			     			  if(datas.flag == "100100")
		 					  {
			     				  layer.msg(datas.message, {icon: 1});
		     				 	  setTimeout(function () {
		     				 		 window.location.href="${basePath}/web/daiHouYw/refundDepositList.jsp";
		     				 	  }, 3000);
		 						  return;
		 					  }
		 					  if(datas.flag == "100200")
		 	                  {
		 						  alert(JSON.stringify(datas));
		 	                	  return;
		 	                  }
		 					  layer.msg(datas.message, {icon: 2});
		                 }
			 	   });
		    	}
	    	}, function(){
	    		layer.msg('已取消本次操作！', {icon: 6});
	    	});
	    }
	    
	    $(function(){	
	        $("#commentForm").validate({
	            rules: {
	            	typeRefund:{
	            		 required: true,
	            	},
	            	bank:{
	            		 required: true,
	            	},
	            	departmentRefund:{
	                    required: true,
	                },
	                cardnoRefund:{
	                    required: true,
	                    bankNum:true,
	                },
	                amountApply:{
	                	required:true,
	                	isMoney:true,
	                },
	                amountRefund:{
	                	required:true,
	                	isMoney:true,
	                },
	            },
	            messages: {
	            	typeRefund:{
	            		 required: "该项必填",
	            	},
	            	bank:{
	            		required: "该项必填",
	            	},
	            	departmentRefund:{
	            		required: "该项必填",
	            		bankNum:"只能输入数字",
	                },
	                cardnoRefund:{
	                	required: "该项必填",
	                },
	                amountApply:{
	                	required: "该项必填",
	                	isMoney:"只能输入数字",
	                },
	                amountRefund:{
	                	required: "该项必填",
	                	isMoney:"只能输入数字",
	                },
	            },
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
		});
    </script>
</body>
</html>
